<template>
<el-dialog title="详情"
           :close-on-click-modal="false" append-to-body
           :visible.sync="visible" class="JNPF-dialog JNPF-dialog_center" lock-scroll
           width="1000px">
<el-row :gutter="15" class="">
<el-form ref="elForm" :model="dataForm" size="medium" label-width="100px" label-position="right" >
    <template v-if="!loading">
            <el-col :span="8" >
                <el-form-item  label="项目"  
 prop="project" >
                         <p>{{ dataForm.project | dynamicText(projectOptions) }} </p>
                </el-form-item>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="关联资产"  
 prop="zcId" >
                         <p>{{ dataForm.zcId | dynamicText(zcIdOptions) }} </p>
                </el-form-item>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="设备名称"  
 prop="equipmentName" >
                         <p>{{ dataForm.equipmentName | dynamicText(equipmentNameOptions) }} </p>
                </el-form-item>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="单价 元/度"  
 prop="price" >
                        <p>{{dataForm.price}}</p>
                </el-form-item>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="设备倍率"  
 prop="equipmentPower" >
                        <p>{{dataForm.equipmentPower}}</p>
                </el-form-item>
            </el-col>
            <el-col :span="24"  >
                <el-divider   content-position="center" >
上期信息             </el-divider>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="上期读数"  
 prop="previousReading" >
                        <p>{{dataForm.previousReading}}</p>
                </el-form-item>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="上期抄录时间"  
 prop="previousTime" >
                        <p>{{jnpf.toDate(dataForm.previousTime,"yyyy-MM-dd")}}</p>
                </el-form-item>
            </el-col>
            <el-col :span="24"  >
                <el-divider   content-position="center" >
本期读数             </el-divider>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="本期读数"  
 prop="currentReading" >
                        <p>{{dataForm.currentReading}}</p>
                </el-form-item>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="本期用量"  
 prop="currentUsage" >
                        <p>{{dataForm.currentUsage}}</p>
                </el-form-item>
            </el-col>
            <el-col :span="8" >
                <el-form-item  label="本期费用"  
 prop="currentCost" >
                        <p>{{dataForm.currentCost}}</p>
                </el-form-item>
            </el-col>
            <el-col :span="24"  >
                <el-divider   content-position="center" >
抄录信息             </el-divider>
            </el-col>
            <el-col :span="10" >
                <el-form-item  label="抄录时间"  
 prop="currentTime" >
                        <p>{{jnpf.toDate(dataForm.currentTime,"yyyy-MM-dd")}}</p>
                </el-form-item>
            </el-col>
            <el-col :span="14" >
                <el-form-item  label="抄录照片"  
 prop="fileAddress" >
                    <JNPF-UploadImg    v-model="dataForm.fileAddress"
 disabled
 detailed  :fileSize="10"  sizeUnit="MB"  :limit="9"  >
                </JNPF-UploadImg>
                </el-form-item>
            </el-col>
    </template>
</el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false"> 取 消</el-button>
    </span>
    </el-dialog>
</template>
<script>
    import request from '@/utils/request'
    import PrintBrowse from '@/components/PrintBrowse'
    import jnpf from '@/utils/jnpf'
    export default {
        components: {PrintBrowse},
        props: [],
        data() {
            return {
                visible: false,
                loading: false,
                printBrowseVisible: false,
                printId: '',
            dataForm: {
                id :'',
                            project : "",
                            zcId : "",
                            equipmentName : "",
                            price : '',
                            equipmentPower : '',
                            previousReading : '',
                            previousTime : '',
                            currentReading : '',
                            currentUsage : '',
                            currentCost : '',
                            currentTime : '',
                            fileAddress : [],
            },
                                projectOptions:[{"fullName":"选项一","id":"1"},{"fullName":"选项二","id":"2"}],
                                zcIdOptions:[{"fullName":"选项一","id":"1"},{"fullName":"选项二","id":"2"}],
                                equipmentNameOptions:[{"fullName":"选项一","id":"1"},{"fullName":"选项二","id":"2"}],

        }
        },
        computed: {},
        watch: {},
        created() {

        },
        mounted() {},
        methods: {
            dataInfo(dataAll){
                let _dataAll =dataAll
                        _dataAll.project = _dataAll.project ? JSON.parse( _dataAll.project):[]
                        _dataAll.zcId = _dataAll.zcId ? JSON.parse( _dataAll.zcId):[]
                        _dataAll.equipmentName = _dataAll.equipmentName ? JSON.parse( _dataAll.equipmentName):[]
                        _dataAll.fileAddress = _dataAll.fileAddress ? JSON.parse( _dataAll.fileAddress):[]
                this.dataForm = _dataAll
            },

            init(id) {
                this.dataForm.id = id || 0;
                this.visible = true;
                this.$nextTick(() => {
                    if(this.dataForm.id){
                        this.loading = true
                        request({
                            url: '/api/example/PropertyMeter/detail/'+this.dataForm.id,
                            method: 'get'
                        }).then(res => {
                            this.dataInfo(res.data)
                            this.loading = false
                        })
                    }

                })
            },
        },
    }

</script>
